package com.core.db.require;

import java.util.ArrayList;
import java.util.List;

import com.core.db.condition.Condition;

/**
 * sql执行请求基类
 * 
 * @author 殷田
 *
 */
public abstract class BaseRequire implements Require
{

	@Override
	public List< String > getColumns()
	{
		List< String > list = new ArrayList< String >();
		List< ColumnDescribe > describes=getColumnDescribes();
		if ( describes != null )
		{
			for ( int i = 0; i < describes.size(); i++ )
			{
				list.add( describes.get( i ).getColumn() );
			}
		}
		return list;
	}

	@Override
	public List< Object > getValues()
	{
		List< Object > list=new ArrayList<Object>();
		List< ColumnDescribe > describes=getColumnDescribes();
		if ( describes != null )
		{
			for ( int i = 0; i < describes.size(); i++ )
			{
				list.add( describes.get( i ).getValue() );
			}
		}
		return list;
	}

	protected String assembleColumns( List< String > columns )
	{
		return null;
	}

	protected String assembleWhere( Condition cond )
	{
		if ( cond != null )
		{
			return cond.where().getSql();
		}
		return "";
	}

	protected String assembleOrder( Condition cond )
	{
		if ( cond != null )
		{
			return cond.order().content();
		}
		return "";
	}

}
